//
//  ZBNetworkManager+Reachability.m
//  ZBDay
//
//  Created by xzb on 2018/2/6.
//  Copyright © 2018年 xzb. All rights reserved.
//

#import "ZBNetworkManager+Reachability.h"

static AFNetworkReachabilityStatus reachabilityStatus;

@implementation ZBNetworkManager (Reachability)


+ (void)rechabilityStatusChangeBlock:(void(^)(AFNetworkReachabilityStatus status))statusBlock
{
    AFNetworkReachabilityManager *mgr = [AFNetworkReachabilityManager sharedManager];
    [mgr setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        reachabilityStatus = status;
        if (statusBlock) {
            statusBlock(status);
        }
    }];
    [mgr startMonitoring];
}

+ (BOOL)reachable
{
    if (reachabilityStatus > 0) {
        return YES;
    }
    return NO;
}

+ (AFNetworkReachabilityStatus)status
{
    return reachabilityStatus;
}

- (void)dealloc
{
    [[AFNetworkReachabilityManager sharedManager] stopMonitoring];
}

@end
